package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.vo.ShopCarVO;
import com.briup.estore.service.ShopCarService;
import com.briup.estore.service.impl.ShopCarServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author briup-adam
 * @Date 2023/8/4 下午4:41
 * @Description 获取用户的购物车列表
 **/

@WebServlet("/shopCar/list")
public class ShopCarListServlet extends  BaseServlet {
    private ShopCarService shopCarService=new ShopCarServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userId = (String) req.getAttribute("userId");
        List<ShopCarVO> list = shopCarService.findLists(Integer.parseInt(userId));
        writeData(resp, Result.success(list));
    }
}
